﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Colder快速开发框架登录</title>
    <!-- Tell the browser to be respodnsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!--bootstrap-->
    <link href="@Url.Scrpit("~/Scripts/vendor/bootstrap/css/bootstrap.min.css")" rel="stylesheet" />
    <!--awesome-->
    <link href="@Url.Scrpit("~/Scripts/vendor/adminlte/dist/css/font-awesome.min.css")" rel="stylesheet" />
    <!-- Ionicons -->
    <link href="@Url.Scrpit("~/Scripts/vendor/adminlte/dist/css/ionicons.min.css")" rel="stylesheet" />
    <!-- Theme style -->
    <link href="@Url.Scrpit("~/Scripts/vendor/adminlte/dist/css/AdminLTE.min.css")" rel="stylesheet" />
    <!-- iCheck -->
    <link href="@Url.Scrpit("~/Scripts/vendor/iCheck/square/blue.css")" rel="stylesheet">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body class="hold-transition login-page" style="height:80%">
    <div class="login-box">
        <div class="login-logo">
            <a href="#"><b>Colder后台登录</b></a>
        </div>
        <!-- /.login-logo -->
        <div class="login-box-body">
            @*<p class="login-box-msg">Sign in to start your session</p>*@
            <form id="form" role="form">
                <div class="form-group has-feedback">
                    <input id="userName" name="userName" type="text" class="form-control" required placeholder="请输入账号">
                    <span class="glyphicon glyphicon-user form-control-feedback"></span>
                    <div class="help-block with-errors"></div>
                </div>
                <div class="form-group has-feedback">
                    <input id="password" name="password" type="password" required class="form-control" placeholder="请输入密码">
                    <span class="glyphicon glyphicon-lock form-control-feedback"></span>
                    <div class="help-block with-errors"></div>
                </div>
                <div class="row">
                    <div class="col-xs-8">
                        <div class="checkbox icheck">
                            <input type="checkbox" id="savePwd"><label style="padding-left:5px" for="savePwd">记住密码</label>
                        </div>
                    </div>
                    <!-- /.col -->
                    <div class="col-xs-4">
                        <button type="submit" class="btn btn-primary btn-block btn-flat">登录</button>
                    </div>
                    <!-- /.col -->
                </div>
            </form>
        </div>
        <!-- /.login-box-body -->
    </div>
    <!-- /.login-box -->
    <!-- jQuery 2.2.3 -->
    <script src="@Url.Scrpit("~/Scripts/vendor/jQuery/jquery-2.2.3.min.js")"></script>

    <!--jQuery-cookie-->
    <script src="@Url.Scrpit("~/Scripts/vendor/jQuery-cookie/jquery.cookie.min.js")"></script>

    <!-- Bootstrap 3.3.6 -->
    <script src="@Url.Scrpit("~/Scripts/vendor/bootstrap/js/bootstrap.min.js")"></script>
    <!-- iCheck -->
    <script src="@Url.Scrpit("~/Scripts/vendor/iCheck/icheck.min.js")"></script>
    <!--bootstrap-validator-->
    <!--bootstrap-->
    <link href="@Url.Scrpit("~/Scripts/vendor/bootstrap/css/bootstrap.min.css")" rel="stylesheet">
    <script src="@Url.Scrpit("~/Scripts/vendor/bootstrap/js/bootstrap.min.js")"></script>
    <script src="@Url.Scrpit("~/Scripts/vendor/bootstrap/js/bootstrap-BtnBuilder.js")"></script>
    <script src="@Url.Scrpit("~/Scripts/vendor/bootstrap-validator/validator.min.js")"></script>
    <!--layer-->
    <script src="@Url.Scrpit("~/Scripts/vendor/layer/layer.js")"></script>
    <script src="@Url.Scrpit("~/Scripts/vendor/layer/layer-extends.js")"></script>
    <!--fx-->
    <script src="@Url.Scrpit("~/Scripts/util/util.js")"></script>

    <script>
        var rootUrl = '@Url.Content("~/")';

        $(function () {
            setPwd();

            $('input').iCheck({
                checkboxClass: 'icheckbox_square-blue',
                radioClass: 'iradio_square-blue',
                increaseArea: '20%' // optional
            });

            //表单校验
            $('#form').validator().on('submit', function (e) {
                //校验成功
                if (!e.isDefaultPrevented()) {
                    e.preventDefault();

                    var values = $('#form').getValues();
                    //保存账号密码
                    var checked = $('#savePwd')[0].checked;
                    savePwd(values.userName, values.password, checked);
                    loading();
                    $.postJSON(rootUrl + 'Home/SubmitLogin', values, function (resJson) {
                        loading(false);

                        if (resJson.Success) {
                            window.location.href = rootUrl;
                        }
                        else {
                            dialogError(resJson.Msg);
                        }
                    });
                }
            })
        });

        //设置保存的账号密码
        function setPwd() {
            var userName = $.cookie('userName');
            var password = $.cookie('password');
            if (userName && password) {
                $('#userName').val(userName);
                $('#password').val(password);
                $('#savePwd').prop('checked', 'checked');
            } else {
                $('#savePwd').removeAttr('checked');
            }
        }

        //保存账号密码
        function savePwd(userName, password, isSave) {
            if (isSave) {
                $.cookie('userName', userName, {
                    expires: new Date('9999/1/1'),
                    path: '/'
                });
                $.cookie('password', password, {
                    expires: new Date('9999/1/1'),
                    path: '/'
                });
            } else {
                $.removeCookie('userName', { path: '/' });
                $.removeCookie('password', { path: '/' });
            }
        }
    </script>
</body>
</html>
